package crm.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;

import crm.dao.ClientsDao;
import crm.dto.Client;

public class ClientsDaoImpl extends HibernateDaoSupport implements ClientsDao {

	@SuppressWarnings("unchecked")
	public List<Client> getClients() {

		DetachedCriteria dc = DetachedCriteria.forEntityName("Client");
		List<Client> list = (List<Client>) getHibernateTemplate()
				.findByCriteria(dc);
		return list;
	}

	@Transactional(readOnly = false)
	public void saveClient(Client client) {
		getHibernateTemplate().saveOrUpdate("Client", client);
	}
}
